<!-- 我的积分 -->
<template>
	<view class="integral" :style="{'--color':vuex_config.themeColor1}">
		<view class="integral_ed" >
			<view class="sum_box">
				<text class="integral_text1">当前积分</text>
				<text class="integral_text2">{{ vuex_count.integral || 0 }}</text>
				<view class="exchange" @click="onClick('/package/integral/index')">兑换产品</view>
			</view>
		</view>
		<view class="blan"></view>
		<view class="integral_integral">
			<view class="title">消费明细</view>
			<view class="integral_item" v-for="(item, index) in dataList" :key="index">
				<view class="integral_text">
					<view class="text1 u-line-1">{{ item.remark }}</view>
					<view class="text3 u-line-1">{{fTime(item.date_creation)}}</view>
				</view>
				<view class="integral_val">
					{{ item.integral }}积分
				</view>
			</view>
			<sww-load-more :params="dataListParams" @load="loadMore"></sww-load-more>
		</view>
	</view>
</template>

<script>
import { pagingMixin } from '@/mixins/pagingMixin.js';
import { formatDate } from '@/utils/moment/index'
import { mapState,mapActions } from 'vuex';
export default {
	mixins: [pagingMixin],
	data() {
		return {
			dataList: [] //积分列表
		};
	},
	computed: {
		...mapState(['vuex_count'])
	},
	onLoad: function() {
		this.getInfo()
		this.initPage();
	},
	onReachBottom: function() {
		this.loadMore();
	},
	methods: {
		...mapActions(['loadUserCount']),
		// 查询个人统计
		getInfo () {
			this.$loading()
			this.loadUserCount().then(()=>{
				this.$hide()
			}).catch(()=>{this.$hide()})
		},
		loadMore() {
			this._load_data();
		},
		// 页面初次渲染
		initPage() {
			this._init_data('GetUsersSignIn',{type:'-1'});
		},
		fTime(time){
			return formatDate(time)
		},
		onClick(url){
			console.log(url)
			this.$to(url)
		}
	}
};
</script>

<style lang="scss" scoped>
.integral {
	width: 100%;
	height: 100%;
}
$h:40rpx;
.integral_ed {
	height: 340rpx;
	color: #fff;
	background-color: var(--color);
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	.sum_box {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		.integral_text1 {
			font-size: 26rpx;
			display: block;
		}

		.integral_text2 {
			font-size: 90rpx;
			font-weight: 700;
		}
		.exchange {
			border: 2rpx solid #fff;
			color: #fff;
			border-radius: 30rpx;
			font-size: 28rpx;
			padding: 2rpx 40rpx;
		}
	}
}
.blan{
	height: $h;
	background-color: var(--color);
}
.integral_integral {
	position: relative;
	margin-top: -$h;
	background-color: #fff;
	border-radius: 20rpx 20rpx 0px 0px;
	padding-top: 10rpx;
	padding: 0 20rpx;
	color: #333;
	.title{
		padding: 20rpx 20rpx 0;
		position: relative;
		display: flex;
		align-items: center;
		height: 44rpx;
		font-weight: bold;
		&::before{
			content: "";
			display: inline-block;
			background: var(--color);
			width: 4rpx;
			height: 26rpx;
			margin-right: 20rpx;
		}
	}
}

.integral_item {
	margin-top: 40rpx;
	height: 74rpx;
	display: flex;
	align-items: center;
}
.color_ccc {
	color: #ccc;
}

.integral_text {
	flex: 1;
	overflow: hidden;
	font-size: 28rpx;
	margin-bottom: 5rpx;
}

.integral_text .text1 {
	color: #333333;
	font-size: 28rpx;
	font-weight: 500;
}

.integral_val{
	color: $sww-theme-price;
}

.integral_item .text3 {
	font-size: 24rpx;
	color: #999;
}

.integral_item .text {
	font-size: 28rpx;
}

.flex {
	display: flex;
	justify-content: space-between;
}
</style>
